<?php

/**
 * This is the model class for table "roles".
 *
 * The followings are the available columns in table 'roles':
 * @property integer $id_rol
 * @property string $nombre_rol
 * @property boolean $consultar_asistencia
 * @property boolean $generar_reporte
 * @property boolean $gestionar_mis_cursos
 * @property boolean $gestionar_cursos
 * @property boolean $gestionar_roles
 * @property boolean $gestionar_recuperacion_clase
 * @property boolean $gestionar_reduccion_asistencia
 * @property boolean $modificar_datos_personales
 * @property boolean $gestionar_materias
 * @property boolean $gestionar_usuarios
 *
 * The followings are the available model relations:
 * @property Usuario[] $usuarios
 */
class Roles extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Roles the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'roles';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nombre_rol, consultar_asistencia, generar_reporte, gestionar_mis_cursos, gestionar_cursos, gestionar_roles, gestionar_recuperacion_clase, gestionar_reduccion_asistencia, modificar_datos_personales, gestionar_materias, gestionar_usuarios', 'required'),
			array('nombre_rol', 'length', 'max'=>250),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_rol, nombre_rol, consultar_asistencia, generar_reporte, gestionar_mis_cursos, gestionar_cursos, gestionar_roles, gestionar_recuperacion_clase, gestionar_reduccion_asistencia, modificar_datos_personales, gestionar_materias, gestionar_usuarios', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'usuarios' => array(self::HAS_MANY, 'Usuario', 'id_rol'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_rol' => 'Id Rol',
			'nombre_rol' => 'Nombre Rol',
			'consultar_asistencia' => 'Consultar Asistencia',
			'generar_reporte' => 'Generar Reporte',
			'gestionar_mis_cursos' => 'Gestionar Mis Cursos',
			'gestionar_cursos' => 'Gestionar Cursos',
			'gestionar_roles' => 'Gestionar Roles',
			'gestionar_recuperacion_clase' => 'Gestionar Recup. Clase',
			'gestionar_reduccion_asistencia' => 'Gestionar Reduc. Asis.',
			'modificar_datos_personales' => 'Mod. Datos Personales',
			'gestionar_materias' => 'Gestionar Materias',
			'gestionar_usuarios' => 'Gestionar Usuarios',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_rol',$this->id_rol);
		$criteria->compare('nombre_rol',$this->nombre_rol,true);
		$criteria->compare('consultar_asistencia',$this->consultar_asistencia);
		$criteria->compare('generar_reporte',$this->generar_reporte);
		$criteria->compare('gestionar_mis_cursos',$this->gestionar_mis_cursos);
		$criteria->compare('gestionar_cursos',$this->gestionar_cursos);
		$criteria->compare('gestionar_roles',$this->gestionar_roles);
		$criteria->compare('gestionar_recuperacion_clase',$this->gestionar_recuperacion_clase);
		$criteria->compare('gestionar_reduccion_asistencia',$this->gestionar_reduccion_asistencia);
		$criteria->compare('modificar_datos_personales',$this->modificar_datos_personales);
		$criteria->compare('gestionar_materias',$this->gestionar_materias);
		$criteria->compare('gestionar_usuarios',$this->gestionar_usuarios);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}